# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=python2-z3
pkgver=4.8.5
pkgrel=1
pkgdesc='High-performance theorem prover.'
url='https://github.com/Z3Prover/z3'
arch=('x86_64' 'aarch64')
license=('MIT')
depends=('python2' 'libz3')
makedepends=('cmake' 'python2' 'python2-setuptools' 'gcc-libs' 'gmp')
source=("https://github.com/Z3Prover/z3/archive/Z3-$pkgver.tar.gz")
sha512sums=('ca36e1a0332bd473a64f41dfdb31656fb3486178473e4fd4934dccce109a84c9686c08f94998df74bacb588eb12ea5db25dc17a564ee76f82fd2559349697309')

prepare() {
  cd "z3-Z3-$pkgver"

  mkdir -p build
}

build() {
  cd "z3-Z3-$pkgver/build"

  cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_INSTALL_LIBDIR=lib -DBUILD_PYTHON_BINDINGS=1 \
    -DPYTHON_EXECUTABLE=/usr/bin/python2 -DUSE_LIB_GMP=1
  make
}

package() {
  cd "z3-Z3-$pkgver/build"

  make DESTDIR="$pkgdir" install

  install -Dm 644 ../LICENSE.txt -t "$pkgdir/usr/share/licenses/$pkgname/"

  cd $pkgdir

  rm -r usr/include usr/bin usr/lib/cmake usr/lib/lib*

  python2 -m compileall .
  python2 -O -m compileall .
}

